<?php

/*
 * Object/EmployeFormation.php
 */

namespace RHX\Model\Object;

use Zend\Db\Adapter\Adapter;

class EmployeFormation {

    public $id;
    public $matricule;
    public $formation_id;
    public $remarque;

    /**
     *
     * @var Adapter
     */
    protected $adapter;

    public function exchangeArray($data = array()) {
	$this->id		 = isset($data['id']) ? $data['id'] : null;
	$this->matricule	 = isset($data['matricule']) ? $data['matricule'] : 0;
	$this->formation_id	 = isset($data['formation_id']) ? $data['formation_id'] : 0;
	$this->remarque		 = isset($data['remarque']) ? $data['remarque'] : '';
    }

    public function __construct(Adapter $adapter, $data = array()) {
	$this->adapter = $adapter;
	$this->exchangeArray($data);
    }

    public function getArrayCopy() {
	return get_object_vars($this);
    }

    /**
     * Formation
     *
     * @return \RHX\Model\Object\Formation
     */
    public function getFormation() {
	$table = new \RHX\Model\Table\FormationTable($this->adapter);

	try {
	    return $table->get($this->formation_id);
	}
	catch (\Exception $ex) {
	    //return new Formation($this->adapter);
	    throw $ex;
	}
    }

    /**
     * Employe
     * 
     * @return \RHX\Model\Object\Employe
     */
    public function getEmploye() {
	$table = new \RHX\Model\Table\EmployeTable($this->adapter);
	try {
	    return $table->get($this->matricule);
	}
	catch (\Exception $ex) {
	    return new Employe($this->adapter);
	}
    }

}

?>
